package com.learning.neo4j.baseapi;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;
import org.neo4j.ogm.annotation.GeneratedValue;
import org.neo4j.ogm.annotation.Id;
import org.neo4j.ogm.annotation.NodeEntity;
import org.neo4j.ogm.annotation.Relationship;

import java.util.HashSet;
import java.util.Set;

/**
 * ClassName: Movie
 * Description:
 * Date: 2019/3/28 11:45 【需求编号】
 *
 * @author Sam Sho
 * @version V1.0.0
 */
@Setter
@Getter
@NodeEntity
public class Movie {
    @Id
    @GeneratedValue
    private Long id;

    private String title;

    private Long released;

    @Relationship(type = "DIRECTED", direction = Relationship.INCOMING)
    private Person directed;

    @Relationship(type = "ACTED_IN", direction = Relationship.INCOMING)
    Set<Person> actors = new HashSet<>();

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }
}
